﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:clr="clr-namespace:System;assembly=mscorlib" xmlns:clr2="clr-namespace:System.Collections;assembly=mscorlib" xmlns:local="clr-namespace:WPG" xmlns:data="clr-namespace:WPG.Data" xmlns:converters="clr-namespace:WPG.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    
	<!-- PropertyGrid Style -->
	<Style TargetType="{x:Type local:PropertyGrid}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:PropertyGrid}">
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition />
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>

						<DockPanel Grid.Row="0" LastChildFill="True">
							<Border DockPanel.Dock="Top" Width="Auto" Height="30" CornerRadius="5,5,0,0" BorderThickness="1,1,1,1" BorderBrush="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=HeaderBorderBrush}}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=HeaderBackgroundBrush}}">
								<TextBlock Text="{TemplateBinding local:PropertyGrid.Headline}" Width="Auto" Height="Auto" Foreground="#FFFFFFFF" Margin="8" HorizontalAlignment="Left" VerticalAlignment="Center" />
							</Border>
							<ScrollViewer Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=ScrollViewerStyle}}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">

								<ItemsControl ItemsSource="{TemplateBinding local:PropertyGrid.Properties}" Background="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=PropertiesBackgroundBrush}}" />
							</ScrollViewer>
						</DockPanel>
						<GridSplitter DataContext="{TemplateBinding local:PropertyGrid.ShowDescription}" Height="3" Grid.ColumnSpan="3" ResizeDirection="Rows" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
							<GridSplitter.Visibility>
								<Binding>
									<Binding.Converter>
										<BooleanToVisibilityConverter />
									</Binding.Converter>
								</Binding>
							</GridSplitter.Visibility>
						</GridSplitter>
						<StackPanel Background="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=ExpanderBackgroundBrush}}" Grid.Row="1" DataContext="{TemplateBinding local:PropertyGrid.ShowDescription}">
							<StackPanel.Visibility>
								<Binding>
									<Binding.Converter>
										<BooleanToVisibilityConverter />
									</Binding.Converter>
								</Binding>
							</StackPanel.Visibility>
                            <TextBlock Padding="2 2 2 0" FontWeight="Bold" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=TextBlockStyle}}" Text="{Binding Name}" DataContext="{TemplateBinding local:PropertyGrid.SelectedProperty}"></TextBlock>
                            <TextBlock Padding="5 2 2 0" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=TextBlockStyle}}" TextWrapping="WrapWithOverflow" Text="{Binding Description}" DataContext="{TemplateBinding local:PropertyGrid.SelectedProperty}"></TextBlock>
						</StackPanel>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>